#ifndef _THREADPOOL_H
#define _THREADPOOL_H

#include <vector>
#include <thread>
#include <functional>

//前置声明--->防止循环包含
//只用用于指针或引用
//优化地
template <typename T>
class BlockingQueue;

class ThreadPool
{
public:
    ThreadPool(short threadnum);
    ~ThreadPool();
    void Post(std::function<void()> task);
    
private:
    void worker();
    //优化地
    std::unique_ptr<BlockingQueue<std::function<void()>>> m_ptask_queue;
    std::vector<std::thread> m_workers;
};

#endif